<template>
  <div style="padding: 24px;">
    <div
      style="font-size: 18px;font-weight: 600;color: #1D2129;margin-bottom: 16px;"
    >
      经费投入
    </div>
    <div>
      <div style="display: flex; width: 100%;">
        <div style="width: 50%;">
          <div style="font-size: 24px;color: #0F0F0F;">34,201</div>
          <div style="font-size: 12px;">累计投入/万元</div>
        </div>
        <div>
          <div style="font-size: 24px;color: #0F0F0F;">34,201</div>
          <div style="font-size: 12px;">上一年度投入总经费/万元</div>
        </div>
      </div>
    </div>
    <div
      style="height: 32px;width: 100%;background: #F7F8FA;margin-top: 17px; line-height: 32px;"
    >
      <div style="font-size: 12px;margin-left: 7px;">
        上一年投入经费详情/万元
      </div>
    </div>
    <div style="display: flex;justify-content: space-between;margin-top: 47px;">
      <div id="Chart6" style="width:50%;height:230px;"></div>
      <div
        style="width:60%;height:198px;padding: 31px 16px; display: flex; flex-wrap: wrap;justify-content: space-between;"
      >
        <div style="display: flex; " v-for="(item, index) in Chartdata">
          <div :style="{ backgroundColor: item.color }" class="dianidan"></div>
          <div>
            <div style="font-size: 12px;margin-right: 7px; width: 116px;">
              \
              {{ item.name }}
            </div>
            <div style="font-size: 22px;color: #0F0F0F;">
              {{ item.value ? item.value : 0 }}
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { get_sheet7_money_data } from "@/api/statistics";
import * as echarts from "echarts";
export default {
  data() {
    return {
      chartInstance: null,
      Chartdata: []
    };
  },
  mounted() {
    this.datalist();
  },

  methods: {
    async datalist() {
      await get_sheet7_money_data().then(res => {
        this.Chartdata = res.data.list;
        this.Chartdata[0].color = "#4E88F5";
        this.Chartdata[1].color = "#EEB74A";
        this.Chartdata[2].color = "#41B776";
      });

      // 基于准备好的dom，初始化echarts实例
      var myChart = echarts.init(document.getElementById("Chart6"));
      // 指定图表的配置项和数据
      var option;
      option;
      option = {
        title: {
          text: "3326",
          left: "center",
          top: "42%",
          textStyle: {
            color: "#333",
            fontSize: 15,
            align: "center"
          }
        },
        tooltip: {
          trigger: "item"
        },

        legend: {
          top: "5%",
          left: "center",
          show: false
        },
        series: [
          {
            type: "pie",
            radius: ["40%", "70%"],
            avoidLabelOverlap: false,
            label: {
              show: false,
              position: "center"
            },
            radius: ["65%", "80%"],

            labelLine: {
              show: false
            },
            data: this.namedata
          }
        ]
      };
      // 使用刚指定的配置项和数据显示图表。
      myChart.setOption(option);
      // 监听父元素大小变化 刷新图表
      var ro = new ResizeObserver(entries => {
        for (let entry of entries) {
          const cr = entry.contentRect;
          myChart.resize();
        }
      });
      ro.observe(Chart6);
    }
  }
};
</script>

<style scoped>
.dianidan {
  width: 7px;
  height: 7px;
  margin-right: 5px;
  margin-top: 3px;
}
</style>
